package com.sky.service.user.impl;

import com.sky.context.BaseContext;
import com.sky.dto.ShoppingCartDTO;
import com.sky.mapper.common.DishMapper;
import com.sky.mapper.common.SetmealMapper;
import com.sky.mapper.user.ShoppingCartMapper;
import com.sky.pojo.ShoppingCart;
import com.sky.service.user.ShoppingCartService;
import com.sky.vo.DishVO;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


import com.sky.service.user.ShoppingCartService;

import java.math.BigDecimal;

@Service
public class ShoppingCartServiceImpl implements ShoppingCartService {
    @Autowired
    private ShoppingCartMapper shoppingCartMapper;
    @Autowired
    private DishMapper dishMapper;
    @Autowired
    private SetmealMapper setmealMapper;
    /**
     * 购物车添加
     *
     * @param dto
     */
    @Override
    public void add(ShoppingCartDTO dto) {
        ShoppingCart shoppingCart=new ShoppingCart();
        BeanUtils.copyProperties(dto,shoppingCart);
        shoppingCart.setUserId(BaseContext.getCurrentId());
        if (dto.getDishId()!=null){
            DishVO info = dishMapper.getInfo(dto.getDishId().intValue());
            shoppingCart.setImage(info.getImage());
            shoppingCart.setAmount(info.getPrice());
            shoppingCart.setDishFlavor(info.getFlavors().toString());
        }if (dto.getSetmealId()!=null){
        
        }

    }
}
